package shapes;

import interfaces.IShapeCreator;
import utilities.DecypherShape;

/**********************************************
 * Cours :			LOG120
 * Session :		Automne 2011
 * Groupe : 		03
 * Projet : 		Lab 1
 * Étudiant(e)(s) : Garcia Carrasco, Maria
 * 					Bolduc, Andrew
 * Code(s) perm. :  GARM05559006
 * 					BOLA03098701
 * Professeur : 	Yannick Boucher
 * Chargé de labo:  Jonathan Simard
 * Nom du fichier : ShapeCreator.java
 * Date crée :      2011-10-11
 **********************************************
 * Historique des modifications
 **********************************************
 * 2011-10-11		Version initiale
 **********************************************
 */

/**
 * @author Maria Garcia Carrasco et Andrew Bolduc
 * Cette classe reçois une String et retourne une forme.
 */

public class ShapeCreator implements IShapeCreator{
	
	/* (non-Javadoc)
	 * @see shapes.IShapeCreator#createShape(java.lang.String)
	 */
	public AbstractShape createShape(String shapeInfo) {
		AbstractShape shape = null;
		DecypherShape shapeDecypherer = new DecypherShape();
		shapeDecypherer.decypherShape(shapeInfo);
		int[] coordinates = shapeDecypherer.getCoordinates();
		
		if(shapeDecypherer.getShape().equalsIgnoreCase(ShapeSettings.getSquareName())) {
			shape = new Rectangle(shapeDecypherer.getId(), shapeDecypherer.getShape(), ShapeSettings.getSquareColor(), coordinates[0], coordinates[1], coordinates[2], coordinates[3]);
		}
		else if(shapeDecypherer.getShape().equalsIgnoreCase(ShapeSettings.getRectangleName())) {
			shape = new Rectangle(shapeDecypherer.getId(), shapeDecypherer.getShape(), ShapeSettings.getRectangleColor(), coordinates[0], coordinates[1], coordinates[2], coordinates[3]);
		}
		else if(shapeDecypherer.getShape().equals(ShapeSettings.getCircleName())) {
			shape = new Oval(shapeDecypherer.getId(), shapeDecypherer.getShape(), ShapeSettings.getCircleColor(), coordinates[0], coordinates[1], coordinates[2], coordinates[2]);
		}
		else if(shapeDecypherer.getShape().equals(ShapeSettings.getOvalName())) {
			shape = new Oval(shapeDecypherer.getId(), shapeDecypherer.getShape(), ShapeSettings.getOvalColor(), coordinates[0], coordinates[1], coordinates[2], coordinates[3]);
		}
		else if(shapeDecypherer.getShape().equals(ShapeSettings.getLineName())) {
			shape = new Line(shapeDecypherer.getId(), shapeDecypherer.getShape(), ShapeSettings.getLineColor(), coordinates[0], coordinates[1], coordinates[2], coordinates[3]);
		}
		
		return shape;
	}

}